/**
 * @description 金融数字，自动补充保留两位小数
 * @param {Number|String} 数字
 * @example onKeyPrice('123') => 123.00
 */
function onKeyPrice(t) {
  t = t.toString();
  if (t == '') {
    return t;
  } else {
    if (t.includes('.')) {
      let floatPart = t.split('.')[1];
      if (floatPart.length == '1') {
        t = t + '0';
      } else if (floatPart.length == 0) {
        t = t + '00';
      }
    } else {
      t = t + '.00';
    }
  }
  return t;
}

export default onKeyPrice;
